<template>
	<view>
		<view class="sbox">
			<view v-if="setList" class="sinfo" v-for="(item,index) in setList" :key="index" @click="pageUrl(item)">
							 <view>{{item.title}}</view>
								<view class="iconfont iconfanhui t-180 black_font"></view>
			</view>
			<view class="sinfo">
				<view class="gt_box">
					<view>个性化推荐</view>
					<view class="gt_msg">如关闭此功能,我们将不再向您提供个性化广告服务及个性化推荐</view>
				</view>
				<u-switch v-model="checked" @change="formSubmit"></u-switch>
			</view>
		     <view v-if="xyList" class="sinfo" v-for="(item,index) in xyList" :key="index" @click="pageUrl(item)">
				 <view>{{item.title}}</view>
					<view class="iconfont iconfanhui t-180 black_font"></view>
			 </view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				xyList: '',
				setList:'',
				checked:false,
			}
		},
		onLoad() {
			this.getSet();
			this.getXy();
			
			this.memberInfo();
		},
		methods:{
			formSubmit() {
				
					let params = {
						is_ts:this.checked?1:0
					}
					console.log(params);
					this.$get(this.$api.userProfile, params, (res) => {
						
					})
				
			},
			memberInfo() {
				let params = {
					token: uni.getStorageSync('userToken')
				}
				this.$get(this.$api.userInfo, params, (res) => {
					let {
						data
					} = res;
					if (data.code == 1) {
						 if(data.data.is_ts==1){
							 this.checked=true;
						 }else{
							 this.checked=false;
						 }
					}
				})
			},
			pageUrl(e) {
				uni.navigateTo({
					url: '/pages/account/treaty?id=' + e.id
				})
			},
			getSet() {
				let _ = this;
				_.$get(_.$api.setList, {
					type: 'app'
				}, (res) => {
					let {
						data
					} = res.data;
					_.setList = data.list;
				});
			},
			getXy() {
				let _ = this;
				_.$get(_.$api.NewsXy, {
					type: 'app'
				}, (res) => {
					let {
						data
					} = res.data;
					_.xyList = data.list;
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.sbox {
		background-color: white;
		box-sizing: border-box;
	}
	.sinfo{
	
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		padding: 30rpx 10rpx;
		border-bottom: 1rpx solid #eee;
	}
	.gt_box{
		width: 80%;
	}
	.gt_msg{
		color: #999999;
		font-size: 26rpx;
	}
</style>